package com.kaifamiao.config;

import com.kaifamiao.handler.HandlerInterceptorDemo;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;


@Configuration
//实现接口需要 @EnableWebMvc,继承类不需要
@EnableWebMvc
@ComponentScan("com.kaifamiao.contraller")
public class SpringMVCConfig implements WebMvcConfigurer {
//public class SpringMVCConfig extends WebMvcConfigurationSupport {

    //配置拦截器
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new HandlerInterceptorDemo())
                .addPathPatterns("/test");
    }


    //静态资源配置
//    @Override
//    public void addResourceHandlers(ResourceHandlerRegistry registry) {
//        registry.addResourceHandler("/static/js/**")
//                .addResourceLocations("/static/js/");
//
//        registry.addResourceHandler("/static/css/**")
//                .addResourceLocations("/static/css/");
//
//    }


}
